package uk.ac.glasgow.demosocs.tests;

import java.util.Date;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;

import uk.ac.glasgow.demosocs.*;
import uk.ac.glasgow.demosocs.impl.*;
import uk.ac.glasgow.demosocs.users.*;

public class StartElectionTest
{
	private VotingSystem vs;

	@Before
	public void setUp()
	{
		vs = new VotingSystemStub();
		vs.setCurrentUser("admin", "passwrd");
		vs.createElection("Test Election", "AV");
	}

	@SuppressWarnings("deprecation")
	@Test 
	public void sampleTest()
	{
		Election e = vs.getCurrentElection();
		assertNotNull(e);
		
		Date startDate = new Date(2012, 2, 28);
		Date endDate = new Date(2012, 4, 4);
		Date openDate = new Date(2012, 2, 25);
		
		// Primary
		vs.editElection(openDate, startDate, endDate, "0");
		assertEquals(ElectionState.STARTED, e.getElectionState());
		
		// Alt
		startDate = new Date(2012, 3, 4);
		vs.editElection(openDate, startDate, endDate, "0");
		assertEquals(ElectionState.NOMINATIONS_OPEN, e.getElectionState());
	}
}